package com.zhongshengnetwork.rightbe.lang.view;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
//import android.support.annotation.NonNull;
//import android.support.v4.app.Fragment;
//import android.support.v4.content.ContextCompat;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.BezierRadarHeader;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.wang.avi.AVLoadingIndicatorView;
import com.zhongshengnetwork.rightbe.Constant.APIKey;
import com.zhongshengnetwork.rightbe.Constant.Constant;
import com.zhongshengnetwork.rightbe.CustomApplication;
import com.zhongshengnetwork.rightbe.R;
import com.zhongshengnetwork.rightbe.common.AppThemeUtils;
import com.zhongshengnetwork.rightbe.common.BaseAnalyticsFragment;
import com.zhongshengnetwork.rightbe.common.CircleTransform;
import com.zhongshengnetwork.rightbe.common.CommonUtils;
import com.zhongshengnetwork.rightbe.common.DateUtil;
import com.zhongshengnetwork.rightbe.common.GsonTools;
import com.zhongshengnetwork.rightbe.common.ScreenUtils;
import com.zhongshengnetwork.rightbe.common.customview.ActionSheetDialog;
import com.zhongshengnetwork.rightbe.common.customview.CustomDialog;
import com.zhongshengnetwork.rightbe.common.expandabletextview.ExpandableTextView;
import com.zhongshengnetwork.rightbe.common.pulluprefresh.xlistview.XListView;
import com.zhongshengnetwork.rightbe.gsonmodel.CollectModel;
import com.zhongshengnetwork.rightbe.gsonmodel.CommonModel;
import com.zhongshengnetwork.rightbe.gsonmodel.DryCommentModel;
import com.zhongshengnetwork.rightbe.gsonmodel.LangInfoModel;
import com.zhongshengnetwork.rightbe.gsonmodel.WeiShuContentDetailModel;
import com.zhongshengnetwork.rightbe.gsonmodel.WeiShuInfoDetailModel;
import com.zhongshengnetwork.rightbe.https.HttpCallBack;
import com.zhongshengnetwork.rightbe.https.HttpsUtils;
import com.zhongshengnetwork.rightbe.lang.activity.BookmarkActivity;
import com.zhongshengnetwork.rightbe.lang.activity.BookmarkCardActivity;
import com.zhongshengnetwork.rightbe.lang.activity.LangCommentActivity;
import com.zhongshengnetwork.rightbe.lang.activity.LangDetailActivity;
import com.zhongshengnetwork.rightbe.lang.activity.LangPublishActivity;
import com.zhongshengnetwork.rightbe.lang.activity.SelfImagePreviewActivity;
import com.zhongshengnetwork.rightbe.lang.activity.UserLangActivity;
import com.zhongshengnetwork.rightbe.lang.res.Configs;
import com.zhongshengnetwork.rightbe.login.LoginActivity;
import com.zhongshengnetwork.rightbe.wzt.activity.WZTActivity;
import com.zhongshengnetwork.rightbe.wzt.activity.WZTContentActivity;
import com.zhongshengnetwork.rightbe.wzt.activity.WZTListActivity;
import com.zhongshengnetwork.rightbe.wzt.model.WZTUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static android.content.Context.CLIPBOARD_SERVICE;

/**
 * Created by luojingxing on 2018/9/7.
 */

public class CollectFragment extends BaseAnalyticsFragment {
    private int pageindex = 0;
    private static final int Records = 20;
    private boolean isHasMore = false;
    private ListView listview;
    private int imgW = 0;
    //加载动画
    private AVLoadingIndicatorView avi;
    private List<CollectModel> list;
    private List<String> moreList;
    private MyAdapter adapter;
    private View rootView;//缓存Fragment view
    private ImageView no_data_img;
    private RefreshLayout mRefreshLayout;
    private ClipboardManager myClipboard;

    private CollectModel collectModel = null;

    //微纸条布局
    private List<WeiShuInfoDetailModel> wztList;
    private int wztW = 0;
    private LinearLayout wzt_header_layout;
    private LinearLayout wzt_header_title;
    private TextView wzt_header_text;

    private LinearLayout wzt_listview_item_layout;
    //图1
    private LinearLayout wzt_layout_1;
    private ImageView wzt_img1;
    private TextView wzt_readcount_1;
    private TextView private_text_1;
    private TextView wzt_text1;
    //图2
    private LinearLayout wzt_layout_2;
    private ImageView wzt_img2;
    private TextView wzt_readcount_2;
    private TextView private_text_2;
    private TextView wzt_text2;
    //图3
    private LinearLayout wzt_layout_3;
    private ImageView wzt_img3;
    private TextView wzt_readcount_3;
    private TextView private_text_3;
    private TextView wzt_text3;

    private String dataContent = "";

    private EditText search_edit;
    private Button search_button;
    private int contentModel = 0;

    private void wztLayout(View parentView){
        if (parentView == null){
            return;
        }
        wzt_header_layout = (LinearLayout) parentView.findViewById(R.id.wzt_header_layout);
        wzt_header_title = (LinearLayout) parentView.findViewById(R.id.wzt_header_title);
        wzt_header_text = (TextView) parentView.findViewById(R.id.wzt_header_text);
        if (wzt_header_layout == null || wzt_header_title == null){
            return;
        }
        wzt_header_title.setClickable(true);
        wzt_header_title.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), WZTListActivity.class);
                intent.putExtra("title","微纸条");
                intent.putExtra("dataType",0);
                startActivity(intent);
            }
        });
        wzt_header_text.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());
        wzt_header_layout.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());

        wzt_listview_item_layout = (LinearLayout) parentView.findViewById(R.id.wzt_listview_item_layout);
        wzt_listview_item_layout.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());
        //图1
        wzt_layout_1 = (LinearLayout) parentView.findViewById(R.id.wzt_layout_1);
        wzt_img1 = (ImageView) parentView.findViewById(R.id.wzt_img1);
        wzt_readcount_1 = (TextView) parentView.findViewById(R.id.wzt_readcount_1);
        private_text_1 = (TextView) parentView.findViewById(R.id.private_text_1);
        wzt_text1 = (TextView) parentView.findViewById(R.id.wzt_text1);
        wzt_text1.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());

        //图2
        wzt_layout_2 = (LinearLayout) parentView.findViewById(R.id.wzt_layout_2);
        wzt_img2 = (ImageView) parentView.findViewById(R.id.wzt_img2);
        wzt_readcount_2 = (TextView) parentView.findViewById(R.id.wzt_readcount_2);
        private_text_2 = (TextView) parentView.findViewById(R.id.private_text_2);
        wzt_text2 = (TextView) parentView.findViewById(R.id.wzt_text2);
        wzt_text2.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());

        //图3
        wzt_layout_3 = (LinearLayout) parentView.findViewById(R.id.wzt_layout_3);
        wzt_img3 = (ImageView) parentView.findViewById(R.id.wzt_img3);
        wzt_readcount_3 = (TextView) parentView.findViewById(R.id.wzt_readcount_3);
        private_text_3 = (TextView) parentView.findViewById(R.id.private_text_3);
        wzt_text3 = (TextView) parentView.findViewById(R.id.wzt_text3);
        wzt_text3.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());
    }

    private void updateWZT(){
        if (wzt_header_layout == null){
            return;
        }
        if (wztList.size() == 0){
            wzt_header_layout.setVisibility(View.GONE);
        }else {
            wzt_header_layout.setVisibility(View.VISIBLE);
            //图1
            wzt_layout_1.setVisibility(View.INVISIBLE);
            wzt_img1.setVisibility(View.INVISIBLE);
            wzt_readcount_1.setVisibility(View.INVISIBLE);
            private_text_1.setVisibility(View.INVISIBLE);
            wzt_text1.setVisibility(View.INVISIBLE);
            //图2
            wzt_layout_2.setVisibility(View.INVISIBLE);
            wzt_img2.setVisibility(View.INVISIBLE);
            wzt_readcount_2.setVisibility(View.INVISIBLE);
            private_text_2.setVisibility(View.INVISIBLE);
            wzt_text2.setVisibility(View.INVISIBLE);
            //图3
            wzt_layout_3.setVisibility(View.INVISIBLE);
            wzt_img3.setVisibility(View.INVISIBLE);
            wzt_readcount_3.setVisibility(View.INVISIBLE);
            private_text_3.setVisibility(View.INVISIBLE);
            wzt_text3.setVisibility(View.INVISIBLE);

            RequestOptions options = new RequestOptions().error(AppThemeUtils.getInstance().getDefaultImageBg()).bitmapTransform(new RoundedCorners(Constant.CornerRadius));//图片圆角
            for (int i = 0; i < wztList.size(); i++){
                WeiShuInfoDetailModel model = wztList.get(i);
                Log.e("微纸条","标题="+model.getTitle()+"\n");
                if (i == 0){
                    wzt_layout_1.setVisibility(View.VISIBLE);
                    wzt_img1.setVisibility(View.VISIBLE);
                    wzt_layout_1.setVisibility(View.VISIBLE);
                    wzt_readcount_1.setVisibility(View.VISIBLE);
                    wzt_text1.setVisibility(View.VISIBLE);
                    ViewGroup.LayoutParams params = wzt_img1.getLayoutParams();
                    params.width =wztW;
                    params.height = wztW;
                    wzt_img1.setLayoutParams(params);
                    params = wzt_text1.getLayoutParams();
                    params.width = wztW;
                    wzt_text1.setLayoutParams(params);
                    Glide.with(getActivity()).load(model.getCover()).apply(options).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(wzt_img1);
                    wzt_text1.setText(model.getTitle());
                    wzt_readcount_1.setText(CommonUtils.getDisplayCount(model.getRealcount()));
                    if (model.getVisible() == false){
                        private_text_1.setVisibility(View.VISIBLE);
                    }

                    wzt_layout_1.setTag(i);
                    wzt_layout_1.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            onClickItem(v);
                        }
                    });

                }else if (i == 1){
                    wzt_layout_2.setVisibility(View.VISIBLE);
                    wzt_img2.setVisibility(View.VISIBLE);
                    wzt_layout_2.setVisibility(View.VISIBLE);
                    wzt_readcount_2.setVisibility(View.VISIBLE);
                    wzt_text2.setVisibility(View.VISIBLE);
                    ViewGroup.LayoutParams params = wzt_img2.getLayoutParams();
                    params.width =wztW;
                    params.height = wztW;
                    wzt_img2.setLayoutParams(params);
                    params = wzt_text2.getLayoutParams();
                    params.width = wztW;
                    wzt_text2.setLayoutParams(params);
                    Glide.with(getActivity()).load(model.getCover()).apply(options).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(wzt_img2);
                    wzt_text2.setText(model.getTitle());
                    wzt_readcount_2.setText(CommonUtils.getDisplayCount(model.getRealcount()));
                    if (model.getVisible() == false){
                        private_text_2.setVisibility(View.VISIBLE);
                    }
                    wzt_layout_2.setTag(i);
                    wzt_layout_2.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            onClickItem(v);
                        }
                    });
                }else if (i == 2){
                    wzt_layout_3.setVisibility(View.VISIBLE);
                    wzt_img3.setVisibility(View.VISIBLE);
                    wzt_layout_3.setVisibility(View.VISIBLE);
                    wzt_readcount_3.setVisibility(View.VISIBLE);
                    wzt_text3.setVisibility(View.VISIBLE);
                    ViewGroup.LayoutParams params = wzt_img3.getLayoutParams();
                    params.width =wztW;
                    params.height = wztW;
                    wzt_img3.setLayoutParams(params);
                    params = wzt_text3.getLayoutParams();
                    params.width = wztW;
                    wzt_text3.setLayoutParams(params);
                    Glide.with(getActivity()).load(model.getCover()).apply(options).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(wzt_img3);
                    wzt_text3.setText(model.getTitle());
                    wzt_readcount_3.setText(CommonUtils.getDisplayCount(model.getRealcount()));
                    if (model.getVisible() == false){
                        private_text_3.setVisibility(View.VISIBLE);
                    }
                    wzt_layout_3.setTag(i);
                    wzt_layout_3.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            onClickItem(v);
                        }
                    });
                }
            }
        }
    }


    private void onClickItem(View v){
        hintKeyBoard();
        WeiShuInfoDetailModel model = wztList.get((int)v.getTag());
        WZTUtils.goToWZT(getActivity(), model);
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (hidden){
            hintKeyBoard();
        }
    }

    public void hintKeyBoard() {
        if (getActivity() == null){
            return;
        }
        //拿到InputMethodManager
        InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        //如果window上view获取焦点 && view不为空
        if (imm.isActive() && getActivity().getCurrentFocus() != null) {
            //拿到view的token 不为空
            if (getActivity().getCurrentFocus().getWindowToken() != null) {
                //表示软键盘窗口总是隐藏，除非开始时以SHOW_FORCED显示。
                imm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            }
        }
    }

    private void onClickSearch(View view){
        hintKeyBoard();
        String text = search_edit.getText().toString();
        dataContent = text;
        if (mRefreshLayout != null){
            Log.e("TAG","进来获取数据了刷新界面");
                /*
                @param delayed 开始延时
                @param duration 拖拽动画持续时间
                @param dragRate 拉拽的高度比率（要求 ≥ 1 ）
                */
            mRefreshLayout.autoRefresh(100,300,1f,false);
        }
    }

    private void calculateImageWidth(){
        int width = ScreenUtils.getScreenWidth(getActivity());
        float density = ScreenUtils.getScreenDensity(getActivity());
        int margin = getResources().getDimensionPixelSize(R.dimen.paddingLR);
        imgW = (int) ((width-100*density)/3);
        wztW = (int) ((width-40*density)/3);
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        calculateImageWidth();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        calculateImageWidth();
        if (rootView == null) {
            myClipboard = (ClipboardManager)getActivity().getSystemService(CLIPBOARD_SERVICE);
            rootView = inflater.inflate(R.layout.my_collect_layout, container, false);
            avi = (AVLoadingIndicatorView)rootView.findViewById(R.id.avi);
            no_data_img = (ImageView)rootView.findViewById(R.id.no_data_img);
            if (moreList == null){
                moreList = new ArrayList<String>();
            }
            if (list == null){
                wztList = new ArrayList<WeiShuInfoDetailModel>();
                list = new ArrayList<CollectModel>();
            }

            search_edit = (EditText) rootView.findViewById(R.id.search_edit);
            search_edit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
                @Override
                public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                    if (i == EditorInfo.IME_ACTION_SEARCH) {
                        String search = search_edit.getText().toString().trim();
                        onClickSearch(textView);
                        return true;
                    }
                    return false;
                }
            });
            search_button = (Button) rootView.findViewById(R.id.search_button);
            search_button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onClickSearch(v);
                }
            });

            listview=(ListView) rootView.findViewById(R.id.collect_listview);
            adapter=new MyAdapter();
            listview.setAdapter(adapter);
            listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    int index = position;// - 1;
                    if (contentModel == 1){
                        index -= 1;
                    }
                    while (index < 0){//解决部分手机点击第一条不是从1开始的问题
                        index+=1;
                    }
                    if (list != null && list.size() > 0 && index < list.size()){
                        collectShare(index, false);
                    }
                    //commentMore(index);
                }
            });
            listview.setOnScrollListener(new AbsListView.OnScrollListener() {
                @Override
                public void onScrollStateChanged(AbsListView absListView, int i) {
                    if (i == SCROLL_STATE_FLING ||
                            i == SCROLL_STATE_TOUCH_SCROLL){
                        hintKeyBoard();
                    }
                }

                @Override
                public void onScroll(AbsListView absListView, int i, int i1, int i2) {

                }
            });

            mRefreshLayout = rootView.findViewById(R.id.refreshLayout);
            //设置 Header 为 贝塞尔雷达 样式
            mRefreshLayout.setRefreshHeader(new BezierRadarHeader(getActivity()).setEnableHorizontalDrag(true));//BezierRadarHeader
            //设置 Footer 为 球脉冲 样式
            mRefreshLayout.setRefreshFooter(new ClassicsFooter(getActivity()).setSpinnerStyle(SpinnerStyle.FixedBehind));//BallPulseFooter ClassicsFooter
            mRefreshLayout.setPrimaryColors(AppThemeUtils.getInstance().getRefreshBackgroundColor(),AppThemeUtils.getInstance().getRefreshAccessColor());
            mRefreshLayout.setEnableRefresh(true);//启用刷新
            mRefreshLayout.setEnableLoadMore(true);//启用加载
            //刷新
            mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
                @Override
                public void onRefresh(RefreshLayout refreshlayout) {
                    //refreshlayout.finishRefresh();
                    pageindex = 0;
                    getData();
                }
            });
            mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
                @Override
                public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                    //refreshLayout.finishLoadMore();
                    loadMore();
                }
            });

            RelativeLayout collect_layout = (RelativeLayout) rootView.findViewById(R.id.collect_layout);
            collect_layout.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());
            listview.setBackgroundColor(AppThemeUtils.getInstance().getBackgroundColor());
            listview.setDivider(new ColorDrawable(AppThemeUtils.getInstance().getBackgroundColor()));
            listview.setDividerHeight((int)(AppThemeUtils.DividerHeight*ScreenUtils.getScreenDensity(CustomApplication.mContext)));

            LinearLayout my_collect_layout = (LinearLayout) rootView.findViewById(R.id.my_collect_layout);
            my_collect_layout.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());
            my_collect_layout.setClickable(true);
            my_collect_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    bookmark(0);
                }
            });
            TextView collect_text = (TextView) rootView.findViewById(R.id.collect_text);
            collect_text.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());

            search_edit.setHintTextColor(AppThemeUtils.getInstance().getLightTextColor());
            search_edit.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());
            RelativeLayout search_top = (RelativeLayout) rootView.findViewById(R.id.search_top);
            search_top.setBackgroundColor(AppThemeUtils.getInstance().getSearchBgColor());
            RelativeLayout search_shape_layout = (RelativeLayout) rootView.findViewById(R.id.search_shape_layout);
            search_shape_layout.setBackgroundResource(AppThemeUtils.getInstance().getSearchBackground());

            getData();
        }else {
            //缓存的rootView需要判断是否已经被加过parent， 如果有parent需要从parent删除，要不然会发生这个rootview已经有parent的错误。
            ViewGroup parent = (ViewGroup) rootView.getParent();
            if (parent != null) {
                parent.removeView(rootView);
            }
        }
        return rootView;
    }

    //加载更多
    private void loadMore(){

        if (search_edit != null){
            if (search_edit.getText() != null){
                String text = search_edit.getText().toString();
                dataContent = text;
            }else {
                dataContent = "";
            }
        }

        final Map<String,String> map = new HashMap<String, String>();
        map.put("pageIndex",pageindex+"");
        map.put("pageRecord",Records+"");
        map.put("token", CustomApplication.loginModel.getToken());
        map.put("text", CommonUtils.formatString(dataContent));
        String url = "miniapp/"+"langappid"+"/getcollection.do";
        HttpsUtils.miniAppDo(map, url,  new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                //listview.stopLoadMore();
                mRefreshLayout.finishLoadMore();
                CommonModel commonModel = GsonTools.getCommonModel(data);
                if (commonModel.getFlag().equals("1")){
                    pageindex += 1;
                    List<CollectModel> l = GsonTools.getCollectModel(data);
                    if (l != null && l.size() > 0){
                        if (l.size() >= Records){
                            //listview.setPullLoadEnable(true);
                            mRefreshLayout.setEnableLoadMore(true);
                        }else {
                            //listview.setPullLoadEnable(false);
                            mRefreshLayout.setEnableLoadMore(false);
                        }
                        list.addAll(l);
                    }else {
                        //listview.setPullLoadEnable(false);
                        mRefreshLayout.setEnableLoadMore(false);
                    }
                    adapter.notifyDataSetChanged();
                }else {
                    CustomApplication.showTip(commonModel, getActivity());
                }
            }

            @Override
            public void onError(String msg) {
                //listview.stopLoadMore();
                mRefreshLayout.finishLoadMore();
            }
        });
    }

    public void getData(){

        hintKeyBoard();
        if (search_edit != null){
            if (search_edit.getText() != null){
                String text = search_edit.getText().toString();
                dataContent = text;
            }else {
                dataContent = "";
            }
        }

        pageindex = 0;
        if (listview == null){
            return;
        }
        if (list == null){
            list = new ArrayList<CollectModel>();
        }
        if (list.size() == 0 && (wztList == null || wztList.size() == 0)){
            no_data_img.setVisibility(View.VISIBLE);
        }

        new Thread(){
            @Override
            public void run() {
                super.run();
                final Map<String,String> map = new HashMap<String, String>();
                map.put("pageIndex",pageindex+"");
                map.put("pageRecord",Records+"");
                map.put("token", CustomApplication.loginModel.getToken());
                map.put("text", CommonUtils.formatString(dataContent));
                String url = "miniapp/"+"langappid"+"/getcollection.do";
                HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                    @Override
                    public void onSuccess(String data) {
                        Log.e("TAG","评论内容："+data);
                        final CommonModel commonModel = GsonTools.getCommonModel(data);
                        if (commonModel.getFlag().equals("1")){
                            final List<CollectModel> l = GsonTools.getCollectModel(data);
                            if (getActivity() == null){
                                return;
                            }
                            getActivity().runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    //listview.stopRefresh(true);
                                    mRefreshLayout.finishRefresh();

                                    if (pageindex == 0){
                                        List<WeiShuInfoDetailModel> wl = GsonTools.getWeiShuInfoDetailModelOfHeader(data);
                                        wztList.clear();
                                        if (wl != null && wl.size() > 0){
                                            contentModel = 1;
                                            wztList.addAll(wl);
                                        }else {
                                            contentModel = 0;
                                        }
                                    }

                                    list.clear();
                                    if (l != null && l.size() > 0){
                                        no_data_img.setVisibility(View.INVISIBLE);
                                        if (l.size() >= Records){
                                            //listview.setPullLoadEnable(true);
                                            mRefreshLayout.setEnableLoadMore(true);
                                        }else {
                                            //listview.setPullLoadEnable(false);
                                            mRefreshLayout.setEnableLoadMore(false);
                                        }
                                        list.addAll(l);
                                    }else {
                                        if (pageindex == 0 && (wztList == null || wztList.size() == 0)){
                                            no_data_img.setVisibility(View.VISIBLE);
                                            //care_circle_button.setVisibility(View.VISIBLE);
                                        }else {
                                            no_data_img.setVisibility(View.INVISIBLE);
                                        }
                                        //listview.setPullLoadEnable(false);
                                        mRefreshLayout.setEnableLoadMore(false);
                                    }
                                    adapter.notifyDataSetChanged();
                                    if (pageindex == 0 && l != null && l.size() > 0){
                                        listview.setSelection(0);
                                    }
                                    if (l != null && l.size() > 0){
                                        pageindex += 1;
                                    }

                                }
                            });
                        }else {
                            if (getActivity() == null){
                                return;
                            }
                            getActivity().runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    //listview.stopRefresh(true);
                                    mRefreshLayout.finishRefresh();
                                    CustomApplication.showTip(commonModel, getActivity());
                                }
                            });
                        }
                    }

                    @Override
                    public void onError(String msg) {
                        if (getActivity() == null){
                            return;
                        }
                        getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                //listview.stopRefresh(true);
                                mRefreshLayout.finishRefresh();
                            }
                        });
                    }
                });
            }
        }.start();
    }

    private class MyAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            if (contentModel == 0){
                return list.size();
            }
            return list.size()+1;
        }


        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            if (contentModel == 0){
                return list.get(position);
            }
            return list.get(position-1);
        }

        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        @Override
        public boolean isEnabled(int position) {
            // TODO Auto-generated method stub
            return super.isEnabled(position);
        }

        @Override
        public int getViewTypeCount() {
            if (contentModel == 0){
                return 1;
            }
            return 2;
        }

        @Override
        public int getItemViewType(int position) {
            if (contentModel == 0){
                return 1;
            }
            if (position == 0){
                return 0;
            }
            return 1;
        }

        /**
         * @param position
         * @param convertView
         * @param parent
         * @return
         */
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            //convertView的复用
            View view = null;
            int type = getItemViewType(position);
            if (type == 0) {
                if (convertView == null) {
                    view = View.inflate(getActivity(), R.layout.wzt_header_layout, null);
                } else {
                    view = convertView;
                    TextView wzt_header_text = view.findViewById(R.id.wzt_header_text);
                    if (wzt_header_text == null){
                        view = View.inflate(getActivity(), R.layout.wzt_header_layout, null);
                    }
                }
                wztLayout(view);
                updateWZT();
                return view;
            }

            if (convertView == null) {
                convertView = View.inflate(getActivity(), R.layout.collect_item,null);
            }
            view=convertView;
            ImageView header = (ImageView) view.findViewById(R.id.lang_user_header);
            if (header == null){
                view = View.inflate(getActivity(), R.layout.collect_item,null);
            }
            //view= LayoutInflater.from(getActivity()).inflate(R.layout.collect_listview_item, null);
            if (contentModel == 1){
                position -= 1;
            }
            CollectModel model = list.get(position);
            if (CommonUtils.isEmpty(model.getTitle())){
                model.setTitle("【纯图片】");
            }

            ImageView lang_user_header = (ImageView) view.findViewById(R.id.lang_user_header);
            ImageView privateIcon = (ImageView) view.findViewById(R.id.private_icon);
            if (!CommonUtils.isEmpty(model.getPrivateIcon())){
                privateIcon.setVisibility(View.VISIBLE);
                Glide.with(getActivity()).load(model.getPrivateIcon()).transform(new CircleTransform(getActivity())).dontAnimate().into(privateIcon);
            }else {
                privateIcon.setVisibility(View.GONE);
            }

            ImageView lang_member_icon = (ImageView) view.findViewById(R.id.lang_member_icon);
            if (!CommonUtils.isEmpty(model.getMemberIcon())){
                lang_member_icon.setVisibility(View.VISIBLE);
                try{
                    Glide.with(getActivity()).load(model.getMemberIcon()).
                            diskCacheStrategy(DiskCacheStrategy.RESOURCE).fitCenter().centerCrop().into(lang_member_icon);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏列表加载图片报错："+e.getLocalizedMessage());
                }

            }else {
                lang_member_icon.setVisibility(View.INVISIBLE);
            }

            FrameLayout lang_user_header_layout = (FrameLayout) view.findViewById(R.id.lang_user_header_layout);
            lang_user_header_layout.setTag(position);
            lang_user_header_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    commentUser((int)v.getTag());
                }
            });
            TextView lang_user_nickname = (TextView) view.findViewById(R.id.lang_user_nickname);
            lang_user_nickname.setTag(position);
            lang_user_nickname.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    commentUser((int)v.getTag());
                }
            });
            TextView lang_time = (TextView) view.findViewById(R.id.lang_time);


            RelativeLayout collect_listview_item_more = (RelativeLayout) view.findViewById(R.id.collect_listview_item_more);
            collect_listview_item_more.setClickable(true);
            collect_listview_item_more.setTag(position);
            collect_listview_item_more.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    commentMore((int)v.getTag());
                }
            });

            ExpandableTextView lang_content = (ExpandableTextView)view.findViewById(R.id.lang_content);
            Glide.with(getActivity()).load(model.getHeader()).transform(new CircleTransform(getActivity())).dontAnimate().into(lang_user_header);
            lang_user_nickname.setText(model.getNickname());

            //最新全部展示时间
            String s1 = model.getTypename();
            String s2 = "  ·  "+DateUtil.getChatDate(Long.valueOf(model.getCollecttime())*1000)+"";
            //lang_time.setText(s1+s2);
            lang_time.setText(s1);
            lang_time.setTag(position);
            lang_time.setFocusable(false);

            lang_content.setText(model.getTitle(),position);
            lang_content.setOnExpandStateChangeListener(new ExpandableTextView.OnExpandStateChangeListener() {
                @Override
                public void onExpandStateChanged(TextView textView, boolean isExpanded) {

                }

                @Override
                public void onClickContentText(int position) {
                    collectShare(position, false);
                }

                @Override
                public void onLongPressContentText(int position) {
                    if (getActivity() == null){
                        return;
                    }
                    if (list == null || list.size() == 0){
                        return;
                    }
                    if (position >= list.size()){
                        return;
                    }
                    if (list == null || list.size() == 0){
                        return;
                    }
                    final CollectModel model = list.get(position);
                    CommonUtils.copy(getActivity(), model.getTitle(), model.isOriginal(), model.getSourceid());
                }

                @Override
                public void onDoubleContentText(int position) {

                }

            });

            //设置主题下的颜色
            RelativeLayout lang_item_layout = (RelativeLayout) view.findViewById(R.id.lang_item_layout);
            lang_item_layout.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());
            lang_user_nickname.setTextColor(AppThemeUtils.getInstance().getUserNameColorOfWeiJu());
            lang_content.mTvContent.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());

            LinearLayout lang_op_layout = (LinearLayout)view.findViewById(R.id.lang_op_layout);
            Button lang_op1 = (Button) view.findViewById(R.id.lang_op1);
            lang_op1.setTag(position);
            lang_op_layout.setVisibility(View.GONE);
            lang_op1.setVisibility(View.GONE);

            LinearLayout up_img_layout = (LinearLayout) view.findViewById(R.id.up_img_layout);
            ImageView up_img_1 = (ImageView) view.findViewById(R.id.up_img_1);
            FrameLayout up_img_1_layout = (FrameLayout) view.findViewById(R.id.up_img_1_layout);
            ImageView up_img_2 = (ImageView) view.findViewById(R.id.up_img_2);
            FrameLayout up_img_2_layout = (FrameLayout) view.findViewById(R.id.up_img_2_layout);
            ImageView up_img_3 = (ImageView) view.findViewById(R.id.up_img_3);
            FrameLayout up_img_3_layout = (FrameLayout) view.findViewById(R.id.up_img_3_layout);


            LinearLayout middle_img_layout = (LinearLayout) view.findViewById(R.id.middle_img_layout);
            ImageView middle_img_1 = (ImageView) view.findViewById(R.id.middle_img_1);
            FrameLayout middle_img_1_layout = (FrameLayout) view.findViewById(R.id.middle_img_1_layout);
            ImageView middle_img_2 = (ImageView) view.findViewById(R.id.middle_img_2);
            FrameLayout middle_img_2_layout = (FrameLayout) view.findViewById(R.id.middle_img_2_layout);
            ImageView middle_img_3 = (ImageView) view.findViewById(R.id.middle_img_3);
            FrameLayout middle_img_3_layout = (FrameLayout) view.findViewById(R.id.middle_img_3_layout);

            LinearLayout down_img_layout = (LinearLayout) view.findViewById(R.id.down_img_layout);
            ImageView down_img_1 = (ImageView) view.findViewById(R.id.down_img_1);
            FrameLayout down_img_1_layout = (FrameLayout) view.findViewById(R.id.down_img_1_layout);
            ImageView down_img_2 = (ImageView) view.findViewById(R.id.down_img_2);
            FrameLayout down_img_2_layout = (FrameLayout) view.findViewById(R.id.down_img_2_layout);
            ImageView down_img_3 = (ImageView) view.findViewById(R.id.down_img_3);
            FrameLayout down_img_3_layout = (FrameLayout) view.findViewById(R.id.down_img_3_layout);

            up_img_layout.setVisibility(View.GONE);
            middle_img_layout.setVisibility(View.GONE);
            down_img_layout.setVisibility(View.GONE);
            if (model.getImglist() == null){

            }else if (model.getImglist().size() == 1){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);

                Glide.with(getActivity()).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);
                //Glide.with(getActivity()).load("https://image.daydayrise.net/clerk_h2.gif").into(up_img_1);
                up_img_2_layout.setVisibility(View.INVISIBLE);
                up_img_2.setVisibility(View.INVISIBLE);
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                up_img_3.setVisibility(View.INVISIBLE);
                up_img_3_layout.setVisibility(View.INVISIBLE);
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);

            }else if (model.getImglist().size() == 2){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);

                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);
                up_img_3.setVisibility(View.INVISIBLE);
                up_img_3_layout.setVisibility(View.INVISIBLE);

            }else if (model.getImglist().size() == 3){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);

                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);

                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);

            }else if (model.getImglist().size() == 4){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);

                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);

                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);

                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                middle_img_2.setVisibility(View.INVISIBLE);
                middle_img_2_layout.setVisibility(View.INVISIBLE);
                middle_img_3.setVisibility(View.INVISIBLE);
                middle_img_3_layout.setVisibility(View.INVISIBLE);

            }else if (model.getImglist().size() == 5){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);

                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);

                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);

                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                middle_img_2.setVisibility(View.VISIBLE);
                middle_img_2_layout.setVisibility(View.VISIBLE);
                middle_img_2_layout.setTag(position+",5");
                middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(4)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_2);
                middle_img_3.setVisibility(View.INVISIBLE);
                middle_img_3_layout.setVisibility(View.INVISIBLE);

            }else if (model.getImglist().size() == 6){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);

                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);

                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);

                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                middle_img_2.setVisibility(View.VISIBLE);
                middle_img_2_layout.setVisibility(View.VISIBLE);
                middle_img_2_layout.setTag(position+",5");
                middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(4)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_2);
                middle_img_3.setVisibility(View.VISIBLE);
                middle_img_3_layout.setVisibility(View.VISIBLE);
                middle_img_3_layout.setTag(position+",6");
                middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(5)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_3);

            }else if (model.getImglist().size() == 7){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);

                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);

                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);

                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                middle_img_2.setVisibility(View.VISIBLE);
                middle_img_2_layout.setVisibility(View.VISIBLE);
                middle_img_2_layout.setTag(position+",5");
                middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(4)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_2);
                middle_img_3.setVisibility(View.VISIBLE);
                middle_img_3_layout.setVisibility(View.VISIBLE);
                middle_img_3_layout.setTag(position+",6");
                middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(5)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_3);

                down_img_layout.setVisibility(View.VISIBLE);
                down_img_1.setVisibility(View.VISIBLE);
                down_img_1_layout.setVisibility(View.VISIBLE);
                down_img_1_layout.setTag(position+",7");
                down_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(6)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_1);
                down_img_2.setVisibility(View.INVISIBLE);
                down_img_2_layout.setVisibility(View.INVISIBLE);
                down_img_3.setVisibility(View.INVISIBLE);
                down_img_3_layout.setVisibility(View.INVISIBLE);
            }else if (model.getImglist().size() == 8){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);

                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);

                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);

                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                middle_img_2.setVisibility(View.VISIBLE);
                middle_img_2_layout.setVisibility(View.VISIBLE);
                middle_img_2_layout.setTag(position+",5");
                middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(4)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_2);
                middle_img_3.setVisibility(View.VISIBLE);
                middle_img_3_layout.setVisibility(View.VISIBLE);
                middle_img_3_layout.setTag(position+",6");
                middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(5)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_3);

                down_img_layout.setVisibility(View.VISIBLE);
                down_img_1.setVisibility(View.VISIBLE);
                down_img_1_layout.setVisibility(View.VISIBLE);
                down_img_1_layout.setTag(position+",7");
                down_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(6)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_1);
                down_img_2.setVisibility(View.VISIBLE);
                down_img_2_layout.setVisibility(View.VISIBLE);
                down_img_2_layout.setTag(position+",8");
                down_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(7)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_2);
                down_img_3.setVisibility(View.INVISIBLE);
                down_img_3_layout.setVisibility(View.INVISIBLE);
            }else if (model.getImglist().size() == 9){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);

                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);

                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);

                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                middle_img_2.setVisibility(View.VISIBLE);
                middle_img_2_layout.setVisibility(View.VISIBLE);
                middle_img_2_layout.setTag(position+",5");
                middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(4)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_2);
                middle_img_3.setVisibility(View.VISIBLE);
                middle_img_3_layout.setVisibility(View.VISIBLE);
                middle_img_3_layout.setTag(position+",6");
                middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(5)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_3);

                down_img_layout.setVisibility(View.VISIBLE);
                down_img_1.setVisibility(View.VISIBLE);
                down_img_1_layout.setVisibility(View.VISIBLE);
                down_img_1_layout.setTag(position+",7");
                down_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_1.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(6)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_1);
                down_img_2.setVisibility(View.VISIBLE);
                down_img_2_layout.setVisibility(View.VISIBLE);
                down_img_2_layout.setTag(position+",8");
                down_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_2.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(7)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_2);
                down_img_3.setVisibility(View.VISIBLE);
                down_img_3_layout.setVisibility(View.VISIBLE);
                down_img_3_layout.setTag(position+",9");
                down_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_3.setLayoutParams(params);
                Glide.with(getActivity()).load(model.getImglist().get(8)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_3);
            }

            RelativeLayout lang_collect = (RelativeLayout) view.findViewById(R.id.lang_collect);
            lang_collect.setTag(position);
            lang_collect.setClickable(true);
            lang_collect.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    //进入收藏夹
                    CollectModel m = list.get((int)view.getTag());
                    bookmark(Integer.valueOf(m.getId()+""));
                }
            });

            RelativeLayout lang_share = (RelativeLayout) view.findViewById(R.id.lang_share);
            lang_share.setTag(position);
            lang_share.setClickable(true);
            lang_share.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    collectShare((int)view.getTag(), true);
                }
            });

            RelativeLayout lang_copy = (RelativeLayout) view.findViewById(R.id.lang_copy);
            lang_copy.setTag(position);
            lang_copy.setClickable(true);
            lang_copy.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    onClickCopy((int)view.getTag(), false);
                }
            });

            RelativeLayout lang_comment = (RelativeLayout) view.findViewById(R.id.lang_comment);
            lang_comment.setTag(position);
            lang_comment.setClickable(true);
            lang_comment.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    collectShare((int)view.getTag(), false);
                }
            });

            return view;
        }
    }

    private void onClickCopy(final int index, boolean isShare){

        hintKeyBoard();

        if (list == null || list.size() == 0){
            return;
        }
        final CollectModel model = list.get(index);
        if (CommonUtils.isEmpty(model.getTitle())){
            return;
        }

        if (model.isOriginal() == true){
            Toast.makeText(getContext(), "亲，原创内容不可以复制哦~",
                    Toast.LENGTH_SHORT).show();
            return;
        }

        if (isShare == false){
            CommonUtils.copy(getActivity(), model.getTitle(), model.isOriginal(), model.getSourceid());
            return;
        }

        try{
            ClipData myClip = ClipData.newPlainText("text", model.getTitle());
            myClipboard.setPrimaryClip(myClip);
            if (isShare == true){
                Toast.makeText(getContext(), "文字已复制，分享启动中...",
                        Toast.LENGTH_SHORT).show();
            }else{
                Toast.makeText(getContext(), "文字已复制~",
                        Toast.LENGTH_SHORT).show();
            }
        }catch (Exception e){

        }
    }

    //进入微句详情
    private void dealWithLang(String langid){
        avi.show();
        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.idKey, langid);
        map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
        String url = "miniapp/langappid/getlanginfo.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                avi.hide();
                CommonModel commonModel = GsonTools.getCommonModel(data);
                if (commonModel.getFlag().equals("1")){
                    LangInfoModel langInfoModel = GsonTools.getLangInfoModel(data);

                    //langInfoModel.setUserid(CustomApplication.loginModel.getUid());
                    //langInfoModel.setHeader(CustomApplication.loginModel.getHeader());
                    //langInfoModel.setNickname(CustomApplication.loginModel.getNickname());
                    //langInfoModel.setIscare(true);
                    if (langInfoModel.getStatus() == 1){
                        Intent intent = new Intent(getActivity(), LangDetailActivity.class);
                        Bundle bundle=new Bundle();
                        bundle.putSerializable("model", langInfoModel);//序列化
                        intent.putExtras(bundle);//发送数据
                        startActivity(intent);
                    }
                }else {
                    CustomApplication.showTip(commonModel, getActivity());
                }
            }

            @Override
            public void onError(String msg) {
                avi.hide();
            }
        });
    }

    //进入评论详情
    private void dealWithComment(String commentid){
        avi.show();
        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.idKey, commentid);
        map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
        String url = "miniapp/langappid/commentcontent.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                avi.hide();
                CommonModel commonModel = GsonTools.getCommonModel(data);
                if (commonModel.getFlag().equals("1")){
                    DryCommentModel model = GsonTools.getCommentModel(data);
                    Intent intent = new Intent(getActivity(),LangCommentActivity.class);
                    intent.putExtra("id",model.getSourceid());
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("DryCommentModel", model);
                    intent.putExtras(bundle);
                    startActivity(intent);
                }else {
                    CustomApplication.showTip(commonModel, getActivity());
                }
            }

            @Override
            public void onError(String msg) {
                avi.hide();
            }
        });
    }

    //点击了评论用户
    private void commentUser(final int index){

        hintKeyBoard();

        if (list == null || list.size() == 0){
            return;
        }
        final CollectModel model = list.get(index);
        //进入个人主页
        Intent intent = new Intent(getActivity(), UserLangActivity.class);
        intent.putExtra(APIKey.useridKey,model.getUserid());
        intent.putExtra(APIKey.typeKey,1);
        intent.putExtra(APIKey.titleKey,model.getNickname());
        startActivity(intent);
    }

    //评论点击更多
    private void commentMore(final int index){

        hintKeyBoard();

        if (list == null || list.size() == 0){
            return;
        }
        final CollectModel model = list.get(index);
        moreList.clear();
        if (model.isdelete() == false){
            if (model.getType() == 0) {//评论
            }else {
                moreList.add("分享");
            }
            if (!CommonUtils.isEmpty(model.getFromSourceId())){
                collectModel = model;
                moreList.add("来源");
            }
            moreList.add("详情");
            moreList.add("复制");
        }
        moreList.add("删除");
        ActionSheetDialog actionSheetDialog = new ActionSheetDialog(getActivity())
                .builder()
                .setTitle("请选择")
                .setCancelable(false)
                .setCanceledOnTouchOutside(true);
        for (String s : moreList){
            actionSheetDialog.addSheetItem(s, null, new ActionSheetDialog.OnSheetItemClickListener() {
                @Override
                public void onClick(int which) {
                    if (which > 0){
                        String title = moreList.get(which-1);
                        if (title.equals("分享")){
                            collectShare(index, true);
                        }else if (title.equals("详情")){
                            collectShare(index, false);
                        }else if (title.equals("删除")){
                            CustomDialog dialog = null;
                            final CustomDialog.Builder builder = new CustomDialog.Builder(getActivity());
                            builder.setTitle("温馨提示");
                            builder.setMessage("确定要删除收藏？");
                            builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    collectDelete(index);
                                }
                            });
                            builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                }
                            });
                            dialog = builder.create();
                            dialog.show();
                        }else if (title.equals("来源")){
                            fromSource();
                        }else if (title.equals("复制")){
                            if (list == null || list.size() == 0){
                                return;
                            }
                            if(index < 0 || index >= list.size()){
                                return;
                            }
                            final CollectModel model = list.get(index);
                            CommonUtils.copy(getActivity(), model.getTitle(), model.isOriginal(), model.getSourceid());
                        }
                    }
                }
            });
        }
        actionSheetDialog.show();
    }

    //收藏删除
    private void collectDelete(final int index){

        hintKeyBoard();

        if (list == null || list.size() == 0){
            return;
        }
        if (CommonUtils.isLogin() == false){
            Intent intent = new Intent(getActivity(),LoginActivity.class);
            startActivity(intent);
            return;
        }
        if(index < 0 || index >= list.size()){
            return;
        }
        final CollectModel model = list.get(index);
        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
        map.put("id", model.getId()+"");
        String url = "miniapp/"+"langappid"+"/canclecollection.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                Log.e("TAG","删除结果："+data);
                avi.hide();
                CommonModel commonModel = GsonTools.getCommonModel(data);
                if (commonModel.getFlag().equals("1")){
                    list.remove(model);
                    adapter.notifyDataSetChanged();
                }else {
                    CustomApplication.showTip(commonModel, getActivity());
                }
            }

            @Override
            public void onError(String msg) {
                avi.hide();
            }
        });
    }

    //进入分享详情
    private void collectShare(final int index, boolean share){

        hintKeyBoard();

        if (getActivity() == null){
            return;
        }
        avi.show();
        final CollectModel model = list.get(index);
        if (model.getType() == 0){//评论

            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.idKey, model.getSourceid());
            map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
            String url = "miniapp/langappid/commentcontent.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    avi.hide();
                    CommonModel commonModel = GsonTools.getCommonModel(data);
                    if (commonModel.getFlag().equals("1")){
                        DryCommentModel model = GsonTools.getCommentModel(data);
                        Intent intent = new Intent(getActivity(),LangCommentActivity.class);
                        intent.putExtra("id",model.getSourceid());
                        intent.putExtra("isShare",share);
                        Bundle bundle = new Bundle();
                        bundle.putSerializable("DryCommentModel", model);
                        intent.putExtras(bundle);
                        startActivity(intent);
                    }else {
                        CustomApplication.showTip(commonModel, getActivity());
                    }
                }

                @Override
                public void onError(String msg) {
                    avi.hide();
                }
            });
        }else if(model.getType() == 1){
            //微句
            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.idKey, model.getSourceid());
            map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
            String url = "miniapp/langappid/getlanginfo.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    avi.hide();
                    CommonModel commonModel = GsonTools.getCommonModel(data);
                    if (commonModel.getFlag().equals("1")){
                        LangInfoModel langInfoModel = GsonTools.getLangInfoModel(data);

                        /*
                        langInfoModel.setUserid(CustomApplication.loginModel.getUid());
                        langInfoModel.setHeader(CustomApplication.loginModel.getHeader());
                        langInfoModel.setNickname(CustomApplication.loginModel.getNickname());
                        langInfoModel.setIscare(true);
                        */

                        if (langInfoModel.getStatus() == 1){
                            Intent intent = new Intent(getActivity(), LangDetailActivity.class);
                            Bundle bundle=new Bundle();
                            bundle.putSerializable("model", langInfoModel);//序列化
                            intent.putExtras(bundle);//发送数据
                            intent.putExtra("share",share);
                            startActivity(intent);
                        }
                    }else {
                        CustomApplication.showTip(commonModel, getActivity());
                    }
                }

                @Override
                public void onError(String msg) {
                    avi.hide();
                }
            });
        }else if (model.getType() == 2){
            //微纸条内容
            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.idKey, model.getSourceid());
            map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
            String url = "weishu/content/info.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    avi.hide();
                    if (getActivity() == null){
                        return;
                    }
                    CommonModel commonModel = GsonTools.getCommonModel(data);
                    if (commonModel.getFlag().equals("1")){
                        WeiShuContentDetailModel langInfoModel = GsonTools.getWeiShuContentDetailModel(data);
                        Intent intent = new Intent(getActivity(), WZTContentActivity.class);
                        Bundle bundle=new Bundle();
                        bundle.putSerializable("model", langInfoModel);//序列化
                        intent.putExtra("share",share);
                        intent.putExtras(bundle);//发送数据
                        startActivity(intent);
                    }else {
                        CustomApplication.showTip(commonModel, getActivity());
                    }
                }

                @Override
                public void onError(String msg) {
                    avi.hide();
                }
            });
        }else if (model.getType() == 3){
            //微纸条评论
            if (getActivity() == null){
                return;
            }
            avi.show();
            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.idKey, model.getSourceid());
            map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
            String url = "weishu/theme/comment/detail.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    avi.hide();
                    if (getActivity() == null){
                        return;
                    }
                    CommonModel commonModel = GsonTools.getCommonModel(data);
                    if (commonModel.getFlag().equals("1")){
                        DryCommentModel model = GsonTools.getCommentModel(data);
                        Intent intent = new Intent(getActivity(),LangCommentActivity.class);
                        intent.putExtra("id",model.getSourceid());
                        intent.putExtra("type",1);
                        Bundle bundle = new Bundle();
                        bundle.putSerializable("DryCommentModel", model);
                        intent.putExtras(bundle);
                        startActivity(intent);
                    }else {
                        CustomApplication.showTip(commonModel, getActivity());
                    }
                }

                @Override
                public void onError(String msg) {
                    avi.hide();
                }
            });
        }
    }

    //点击图片处理
    private void onClickImageView(final View view){

        hintKeyBoard();

        if (list == null || list.size() == 0){
            return;
        }

        if (getActivity() == null){
            return;
        }

        if (CustomApplication.isWatchingImg == true){
            return;
        }
        CustomApplication.isWatchingImg = true;

        String tag = view.getTag().toString();
        List<String> l = CommonUtils.stringToArrayList(tag);
        CollectModel model = list.get(Integer.valueOf(l.get(0)));
        int position = Integer.valueOf(l.get(1))-1;


        Intent intent = new Intent(getActivity(), SelfImagePreviewActivity.class);
        intent.putExtra("position",position);
        intent.putExtra("isListImg",true);
        intent.putExtra("imgs",model.getImg());
        //View代表方法传入的控件
        int[] viewLocation = new int[2];
        view.getLocationInWindow(viewLocation);
        int viewX = viewLocation[0]; // x 坐标
        int viewY = viewLocation[1]-(int) (20*ScreenUtils.getScreenDensity(CustomApplication.mContext)); // y 坐标，这里当顶部有状态栏时，要减去状态栏的高度
        intent.putExtra("viewX",viewX);
        intent.putExtra("viewY",viewY);
        intent.putExtra("imgW",imgW);
        intent.putExtra("imgH",imgW);
        getActivity().startActivity(intent);
        getActivity().overridePendingTransition(0,0);//可以通过参数设置关闭与要显示的动画效果,0表示无效果.

    }

    //加入收藏夹
    private void bookmark(int id){
        Intent intent = new Intent(getActivity(), BookmarkActivity.class);
        intent.putExtra("id",id);
        getActivity().startActivity(intent);
    }

    private void fromSource(){
        if (collectModel != null){
            if (collectModel.getType() == 0){//评论
                final HashMap<String, String> map = new HashMap<String, String>();
                map.put(APIKey.idKey, collectModel.getFromSourceId());
                if (CommonUtils.isLogin() == true){
                    map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
                }
                String url = "miniapp/langappid/getlanginfo.do";
                HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                    @Override
                    public void onSuccess(String data) {
                        avi.hide();
                        CommonModel commonModel = GsonTools.getCommonModel(data);
                        if (commonModel.getFlag().equals("1")){
                            LangInfoModel langInfoModel = GsonTools.getLangInfoModel(data);
                            if (langInfoModel.getStatus() == 1){
                                Intent intent = new Intent(getActivity(), LangDetailActivity.class);
                                Bundle bundle=new Bundle();
                                bundle.putSerializable("model", langInfoModel);//序列化
                                intent.putExtras(bundle);//发送数据
                                intent.putExtra("share",false);
                                startActivity(intent);
                            }
                        }else {
                            CustomApplication.showTip(commonModel, getActivity());
                        }
                    }

                    @Override
                    public void onError(String msg) {
                        avi.hide();
                    }
                });
            }else if (collectModel.getType() == 2){//微纸条内容
                dealWithWZT(collectModel.getFromSourceId(), 0);
            }else if (collectModel.getType() == 3){//微纸条评论
                if (CommonUtils.isNumber(collectModel.getFromSourceId())){
                    dealWithWZT(collectModel.getFromSourceId(), 1);
                }else {
                    dealWithWZTContent(collectModel.getFromSourceId());
                }
            }
        }
    }

    private void dealWithWZT(String id, final int selectIndex){
        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.idKey, id);
        if (CommonUtils.isLogin() == true){
            map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
        }
        String url = "weishu/theme/info.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                CommonModel commonModel = GsonTools.getCommonModel(data);
                if (commonModel.getFlag().equals("1")){
                    WeiShuInfoDetailModel langInfoModel = GsonTools.getWeiShuInfo(data);

                    if (CommonUtils.isLogin() == true && CustomApplication.loginModel.getUid().equals(langInfoModel.getUserid())){
                        Intent intent = new Intent(getActivity(), WZTActivity.class);
                        Bundle bundle=new Bundle();
                        bundle.putSerializable("model", langInfoModel);//序列化
                        intent.putExtras(bundle);//发送数据
                        intent.putExtra("selectIndex",selectIndex);
                        startActivity(intent);
                    }else {
                        WZTUtils.goToWZT(getActivity(),langInfoModel);
                    }
                }else {
                    CustomApplication.showTip(commonModel, getActivity());
                }
            }

            @Override
            public void onError(String msg) {
            }
        });
    }

    private void dealWithWZTContent(String langid){
        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.idKey, langid);
        if (CommonUtils.isLogin() == true){
            map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
        }
        String url = "weishu/content/info.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                CommonModel commonModel = GsonTools.getCommonModel(data);
                if (commonModel.getFlag().equals("1")){
                    WeiShuContentDetailModel langInfoModel = GsonTools.getWeiShuContentDetailModel(data);
                    Intent intent = new Intent(getActivity(), WZTContentActivity.class);
                    Bundle bundle=new Bundle();
                    bundle.putSerializable("model", langInfoModel);//序列化
                    intent.putExtras(bundle);//发送数据
                    startActivity(intent);
                }else {
                    CustomApplication.showTip(commonModel, getActivity());
                }
            }

            @Override
            public void onError(String msg) {
            }
        });
    }

}

